package com.jt.tenant.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.jt.tenant.R;
import com.jt.tenant.app.JTApplication;
import com.jt.tenant.conn.GetReportList;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by Administrator on 2016/2/16.
 */
public class ReportAdapter extends BaseAdapter {

    private LayoutInflater layoutInflater;

    private List<GetReportList.Info> list;

    public ReportAdapter(Context context, List<GetReportList.Info> list) {

        layoutInflater = ((Activity) context).getLayoutInflater();

        this.list = list;

    }

    @Override
    public int getCount() {

        return list.size();

    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;

        if (convertView == null) {

            convertView = JTApplication.ScaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_report, null));

            holder = new ViewHolder();

            holder.item_report_name = (TextView) convertView.findViewById(R.id.item_report_name);

            holder.item_report_time = (TextView) convertView.findViewById(R.id.item_report_time);

            convertView.setTag(holder);

        } else {

            holder = (ViewHolder) convertView.getTag();

        }

        holder.item_report_name.setText("诊断报告：" + list.get(position).id);

        Double time_d = Double.parseDouble(list.get(position).scoreDate);

        holder.item_report_time.setText(new SimpleDateFormat("yyyy/MM/dd").format(time_d));

        return convertView;

    }

    private class ViewHolder {

        private TextView item_report_name;

        private TextView item_report_time;

    }

}
